using System.Web;
using Castle.MonoRail.Framework;
using KenEgozi.Com.Weblog.Application;
using System.Drawing.Imaging;

namespace KenEgozi.Com.Weblog.Controllers
{
	[Layout("Default")]
	public class ImagesController : Controller
	{
		[Cache(HttpCacheability.NoCache)]
		public void Captcha()
		{
			CancelView();
			CancelLayout();
			Response.Clear();
			Response.ContentType = "image/jpeg";

			string captchaCode = Session["captcha"] as string;
			if (captchaCode == null)
			{
				return;
			}
			CaptchaImage captcha = new CaptchaImage(captchaCode.ToUpper(), 150, 60);
			captcha.Image.Save(Response.OutputStream, ImageFormat.Jpeg);
			captcha.Dispose();
		}
	}
}
